<template>
	<view>
		<view class="" v-for="(item,index) in queryData" :key='index' v-if="queryData != []">
			<view class="code">
				<view class="code_title flex-direction">
					<text>名字：{{item.contacts}}</text>
					<text>电话：{{item.phone}}</text>
				</view>
				<view class="code_place">
					<text>地址：{{item.address}}</text>
				</view>
				<view class="code_img" v-for="(img,ind) in item.img_arr" :key="ind">
					<image :src="img" mode="" @click="previewImg(item.img_arr)"></image>
				</view>
			</view>
		</view>
		<view class="content" v-else>
			<image src="../../static/logo.png" mode=""></image>
			<button class="cu-btn bg-green margin-tb-sm lg" @click="returnAdd">没有数据 去添加数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryData: [],
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			async init() {
				// 传过去的查询参数
				let data = {
					testId: 1
				}
				// 查询请求
				let res = await this.$operate.uniCloud('query_list', data)
				console.log(res);
				this.queryData = res.result.data.data
			},
			returnAdd() {
				uni.navigateBack({
					delta: 1
				})
			},
			previewImg(img){
				uni.previewImage({
					urls:img,
					success(res) {
						console.log(res);
					},
				})
			}
		}
	}
</script>

<style lang="scss">
	.code {
		font-size: 30rpx;
		color: #333333;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		margin: 20rpx;
		padding: 20rpx;

		.code_title {
			line-height: 50rpx;
			display: flex;
		}

		.code_place {
			line-height: 30rpx;
			color: #CCCCCC;
			margin-top: 10rpx;
		}

		.code_img {
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: left;
			flex-wrap: wrap;

			image {
				width: 130rpx;
				height: 130rpx;
				margin-right: 15rpx;
			}
		}
	}

	.content {
		padding-top: 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;

		image {
			height: 200rpx;
			width: 200rpx;

		}
	}
</style>
